<template>
 <div class="firstList">
   <h3 class="title">
     <span class="t">系统动态</span>
     <router-link @click="top" :to="`../list/${itemId}?key=系统动态`">查看更多 <RightOutlined /></router-link>
   </h3>

    <div class="picBox">
      <div class="pic" v-for="item in ArticleList" :key="item.article_id">
        <Image width="100%" :height="267" :src="`${api}/a/file/thumb/${item.cover_img_id}/370x267`"
               :fallback="stPic"/>
      </div>
      <h3 v-for="item in ArticleList" :key="item.article_id">
<!--     <a target="_blank" :href="`../article/${itemId}?id=${item.article_id}`">{{ item.article_title }}</a>-->
        <a target="_blank" :href="`/articleDetail/${item.article_id}`"> {{ item.article_title }} </a>
      </h3>

      <div class="pt80" v-if="!ArticleList.length">
        <Empty description="暂无数据"/>
      </div>
    </div>
 </div>
</template>

<script lang="ts" >
import {defineComponent, inject, onMounted, ref} from "vue";
import { Row, Col , Image , Empty} from "ant-design-vue";
import { RightOutlined } from '@ant-design/icons-vue';
import stPic from '/public/resource/image/st.png';
import {getArticleListApi, getItemTreeApi} from "/@/api/theme";
import {findOneDataObj,api,top} from "/@/utils";


export default defineComponent({
  name: "dynamic",
  components: { Row, Col , RightOutlined , Image , Empty},
  setup() {
    const itemId = inject('itemId') as string;

    const ArticleList = ref([]);

    const getItemTree = async () => {
      const Param = { includeSelf:false,itemId:itemId }
      let { success , data } = await getItemTreeApi(Param);
      if(success){
        let noticeObj = findOneDataObj(data,'系统动态')
        getItemList(noticeObj.data.itemId)
      }
    }

    const getItemList = x => {
      const Param = { current:1,size:1,itemId: x }
      getArticleListApi(Param).then(({ success , data })=>{
        if(success){
          let { total , records } = data;
          if(total) ArticleList.value = records
        }
      })
    }
    const init = () => {
      getItemTree();
    }
    onMounted(init)

    return {
      itemId , top , ArticleList,api,stPic
    };
  }
});
</script>

<style lang="less" scoped>
.firstList{
  .title{
    margin-bottom: 0;

    span.t{
      display: inline-block;
      padding-bottom: 10px;
      font-size: 20px;
      line-height: 28px;
    }

    a{
      float: right;
      font-size: 14px;
      transform: translateY(5px);

      .anticon{
        font-size: 14px;
      }
    }

  }

}

.picBox {
  width: 370px;
  min-height: 254px;

  .pic  {
    width: 370px;
  }

  h3{
    padding-top: 10px;
    overflow: hidden;
    font-size: 16px;
    font-weight: bold;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

::v-deep(.ant-image-img) {
  max-height: 100%;
}

</style>
